home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue26 / survive / BUILDER1.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1997-08-20  |  1.6 KB  |  76 lines

  1. unit builder1;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  7.   DB, DBTables, StdCtrls, ExtCtrls, DBCtrls, Grids, DBGrids;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     Table1: TTable;
  12.     DataSource1: TDataSource;
  13.     DBGrid1: TDBGrid;
  14.     DBNavigator1: TDBNavigator;
  15.     Button1: TButton;
  16.     procedure Button1Click(Sender: TObject);
  17.   private
  18.   public
  19.   end;
  20.  
  21. var
  22.   Form1: TForm1;
  23.  
  24. implementation
  25.  
  26. {$R *.DFM}
  27.  
  28. procedure TForm1.Button1Click(Sender: TObject);
  29. type
  30.   TTestRec = packed record
  31.       DelFlag: Byte;
  32.       EmpNo: SmallInt;
  33.       FirstName: string[15];
  34.       LastName: string[20];
  35.       HireDate: TDateTime;
  36.       DeptNo: string[3];
  37.       Salary: Double;
  38.       NullFlags: LongInt;
  39.     end;
  40. var
  41.   OutFile: file of TTestRec;
  42.   OutRec: TTestRec;
  43. begin
  44.   AssignFile(OutFile, 'Test0.Dat');
  45.   Rewrite(OutFile);
  46.   try
  47.     with Table1 do begin
  48.       Open;
  49.       try
  50.         while not Eof do begin
  51.           with OutRec do begin
  52.             DelFlag := 0;
  53.             EmpNo := FieldByName('Emp_No').AsInteger;
  54.             FirstName := FieldByName('First_Name').AsString;
  55.             LastName := FieldByName('Last_Name').AsString;
  56.             HireDate := FieldByName('Hire_Date').AsDateTime;
  57.             DeptNo := FieldByName('Dept_No').AsString;
  58.             Salary := FieldByName('Salary').AsFloat;
  59.             NullFlags := 0;
  60.           end;
  61.  
  62.           Write(OutFile, OutRec);
  63.  
  64.           Next;
  65.         end;
  66.       finally
  67.         Close;
  68.       end;
  69.     end;
  70.   finally
  71.     CloseFile(OutFile);
  72.   end;
  73. end;
  74.  
  75. end.
  76.